# -*- coding: utf-8 -*-
"""
Created on Mon Apr 22 20:47:39 2019

@author: yaoyu
"""

import numpy as np

def pySum():
    a = [0, 1, 2, 3, 4]
    b = [9, 8, 7, 6, 5]
    c = []
    
    for i in range(len(a)):
        c.append(a[i]**2 + b[i]**3)
    return c

def npSum():
    a = np.array([0, 1, 2, 3, 4])
    b = np.array([9, 8, 7, 6, 5])
    
    c = a**2 + b**3
    
    return c

def _print(*args, **kwargs):
    print(*args, **kwargs)
    print('='*30)

print(pySum())
print(npSum())

x = np.array([0,1,2,3])
print(x)

x = np.array([[1,2], [9,8], (0.1,0.2)])
print(x)

x = np.ones((2,3,4))
print(x)
print(x.shape)

a = np.linspace(1, 10, 4)

a = np.linspace(1, 10, 4)
print(a)

b = np.linspace(1, 10, 4, endpoint=False)
print(b)

c = np.concatenate((a, b))
print(c)

print('---------------')
a = np.ones((2,3,4),np.int32)
print(a)

print('---------------')
a.reshape((3,8))
print(a)

a.resize((3,8))
print(a)
print('='*30)

a = np.ones((2,3,4),np.int)
print(a)
print('='*30)

b = a.astype(np.float)
print(b)
print('='*30)

a = np.full((2,3,4), 25, np.int32)
print(a)
print('='*30)

print(a.tolist())
print('='*30)

a = np.arange(24).reshape((2,3,4))
_print(a)

_print(a[0,1,2])
_print(a[-1,-2,-3])

_print(a[:, 1, -3])
_print(a[:, 1:3, :])
_print(a[:, :, ::2])

_print(a.mean())
_print(a/a.mean())

_print(np.square(a))
_print(np.modf(np.sqrt(a)))

b = np.sqrt(a)
_print(np.maximum(a,b))

_print(a>b)